.class public Lorg/microemu/device/impl/Polygon;
.super Lorg/microemu/device/impl/Shape;
.source "Polygon.java"


# instance fields
.field private bounds:Lorg/microemu/device/impl/Rectangle;

.field public npoints:I

.field public xpoints:[I

.field public ypoints:[I


# direct methods
.method public constructor <init>()V
    .locals 1

    .prologue
    .line 54
    invoke-direct {p0}, Lorg/microemu/device/impl/Shape;-><init>()V

    .line 49
    new-instance v0, Lorg/microemu/device/impl/Rectangle;

    invoke-direct {v0}, Lorg/microemu/device/impl/Rectangle;-><init>()V

    iput-object v0, p0, Lorg/microemu/device/impl/Polygon;->bounds:Lorg/microemu/device/impl/Rectangle;

    .line 55
    return-void
.end method

.method public constructor <init>(Lorg/microemu/device/impl/Polygon;)V
    .locals 3
    .parameter "poly"

    .prologue
    .line 87
    iget-object v0, p1, Lorg/microemu/device/impl/Polygon;->xpoints:[I

    iget-object v1, p1, Lorg/microemu/device/impl/Polygon;->ypoints:[I

    iget v2, p1, Lorg/microemu/device/impl/Polygon;->npoints:I

    invoke-direct {p0, v0, v1, v2}, Lorg/microemu/device/impl/Polygon;-><init>([I[II)V

    .line 88
    return-void
.end method

.method public constructor <init>([I[II)V
    .locals 4
    .parameter "xpoints"
    .parameter "ypoints"
    .parameter "npoints"

    .prologue
    const/4 v2, 0x0

    .line 67
    invoke-direct {p0}, Lorg/microemu/device/impl/Shape;-><init>()V

    .line 49
    new-instance v1, Lorg/microemu/device/impl/Rectangle;

    invoke-direct {v1}, Lorg/microemu/device/impl/Rectangle;-><init>()V

    iput-object v1, p0, Lorg/microemu/device/impl/Polygon;->bounds:Lorg/microemu/device/impl/Rectangle;

    .line 69
    new-array v1, p3, [I

    iput-object v1, p0, Lorg/microemu/device/impl/Polygon;->xpoints:[I

    .line 70
    new-array v1, p3, [I

    iput-object v1, p0, Lorg/microemu/device/impl/Polygon;->ypoints:[I

    .line 71
    iput p3, p0, Lorg/microemu/device/impl/Polygon;->npoints:I

    .line 73
    iget-object v1, p0, Lorg/microemu/device/impl/Polygon;->xpoints:[I

    invoke-static {p1, v2, v1, v2, p3}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V

    .line 74
    iget-object v1, p0, Lorg/microemu/device/impl/Polygon;->ypoints:[I

    invoke-static {p2, v2, v1, v2, p3}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V

    .line 76
    const/4 v0, 0x0

    .local v0, i:I
    :goto_0
    if-ge v0, p3, :cond_0

    .line 77
    iget-object v1, p0, Lorg/microemu/device/impl/Polygon;->bounds:Lorg/microemu/device/impl/Rectangle;

    aget v2, p1, v0

    aget v3, p2, v0

    invoke-virtual {v1, v2, v3}, Lorg/microemu/device/impl/Rectangle;->add(II)V

    .line 76
    add-int/lit8 v0, v0, 0x1

    goto :goto_0

    .line 79
    :cond_0
    return-void
.end method


# virtual methods
.method public addPoint(II)V
    .locals 6
    .parameter "x"
    .parameter "y"

    .prologue
    const/4 v5, 0x1

    const/4 v4, 0x0

    .line 97
    iget v2, p0, Lorg/microemu/device/impl/Polygon;->npoints:I

    if-lez v2, :cond_0

    .line 100
    iget-object v0, p0, Lorg/microemu/device/impl/Polygon;->xpoints:[I

    .line 101
    .local v0, xtemp:[I
    iget-object v1, p0, Lorg/microemu/device/impl/Polygon;->ypoints:[I

    .line 102
    .local v1, ytemp:[I
    iget v2, p0, Lorg/microemu/device/impl/Polygon;->npoints:I

    add-int/lit8 v2, v2, 0x1

    new-array v2, v2, [I

    iput-object v2, p0, Lorg/microemu/device/impl/Polygon;->xpoints:[I

    .line 104
    iget-object v2, p0, Lorg/microemu/device/impl/Polygon;->xpoints:[I

    iget v3, p0, Lorg/microemu/device/impl/Polygon;->npoints:I

    invoke-static {v0, v4, v2, v4, v3}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V

    .line 105
    const/4 v0, 0x0

    .line 106
    iget v2, p0, Lorg/microemu/device/impl/Polygon;->npoints:I

    add-int/lit8 v2, v2, 0x1

    new-array v2, v2, [I

    iput-object v2, p0, Lorg/microemu/device/impl/Polygon;->ypoints:[I

    .line 107
    iget-object v2, p0, Lorg/microemu/device/impl/Polygon;->ypoints:[I

    iget v3, p0, Lorg/microemu/device/impl/Polygon;->npoints:I

    invoke-static {v1, v4, v2, v4, v3}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V

    .line 113
    .end local v0           #xtemp:[I
    .end local v1           #ytemp:[I
    :goto_0
    iget v2, p0, Lorg/microemu/device/impl/Polygon;->npoints:I

    add-int/lit8 v2, v2, 0x1

    iput v2, p0, Lorg/microemu/device/impl/Polygon;->npoints:I

    .line 114
    iget-object v2, p0, Lorg/microemu/device/impl/Polygon;->xpoints:[I

    iget v3, p0, Lorg/microemu/device/impl/Polygon;->npoints:I

    sub-int/2addr v3, v5

    aput p1, v2, v3

    .line 115
    iget-object v2, p0, Lorg/microemu/device/impl/Polygon;->ypoints:[I

    iget v3, p0, Lorg/microemu/device/impl/Polygon;->npoints:I

    sub-int/2addr v3, v5

    aput p2, v2, v3

    .line 117
    iget-object v2, p0, Lorg/microemu/device/impl/Polygon;->bounds:Lorg/microemu/device/impl/Rectangle;

    invoke-virtual {v2, p1, p2}, Lorg/microemu/device/impl/Rectangle;->add(II)V

    .line 118
    return-void

    .line 110
    :cond_0
    new-array v2, v5, [I

    iput-object v2, p0, Lorg/microemu/device/impl/Polygon;->xpoints:[I

    .line 111
    new-array v2, v5, [I

    iput-object v2, p0, Lorg/microemu/device/impl/Polygon;->ypoints:[I

    goto :goto_0
.end method

.method public contains(II)Z
    .locals 12
    .parameter "x"
    .parameter "y"

    .prologue
    const/4 v11, 0x1

    const/4 v10, 0x0

    .line 137
    invoke-virtual {p0}, Lorg/microemu/device/impl/Polygon;->getBounds()Lorg/microemu/device/impl/Rectangle;

    move-result-object v4

    invoke-virtual {v4, p1, p2}, Lorg/microemu/device/impl/Rectangle;->contains(II)Z

    move-result v4

    if-eqz v4, :cond_5

    .line 140
    const/4 v0, 0x0

    .line 141
    .local v0, c:Z
    const/4 v1, 0x0

    .local v1, i:I
    iget v4, p0, Lorg/microemu/device/impl/Polygon;->npoints:I

    sub-int v3, v4, v11

    .local v3, j:I
    :goto_0
    iget v4, p0, Lorg/microemu/device/impl/Polygon;->npoints:I

    if-ge v1, v4, :cond_4

    .line 142
    iget-object v4, p0, Lorg/microemu/device/impl/Polygon;->ypoints:[I

    aget v4, v4, v1

    if-gt v4, p2, :cond_0

    iget-object v4, p0, Lorg/microemu/device/impl/Polygon;->ypoints:[I

    aget v4, v4, v3

    if-lt p2, v4, :cond_1

    :cond_0
    iget-object v4, p0, Lorg/microemu/device/impl/Polygon;->ypoints:[I

    aget v4, v4, v3

    if-gt v4, p2, :cond_2

    iget-object v4, p0, Lorg/microemu/device/impl/Polygon;->ypoints:[I

    aget v4, v4, v1

    if-ge p2, v4, :cond_2

    :cond_1
    int-to-double v4, p1

    iget-object v6, p0, Lorg/microemu/device/impl/Polygon;->xpoints:[I

    aget v6, v6, v3

    iget-object v7, p0, Lorg/microemu/device/impl/Polygon;->xpoints:[I

    aget v7, v7, v1

    sub-int/2addr v6, v7

    int-to-double v6, v6

    iget-object v8, p0, Lorg/microemu/device/impl/Polygon;->ypoints:[I

    aget v8, v8, v1

    sub-int v8, p2, v8

    int-to-double v8, v8

    mul-double/2addr v6, v8

    iget-object v8, p0, Lorg/microemu/device/impl/Polygon;->ypoints:[I

    aget v8, v8, v3

    iget-object v9, p0, Lorg/microemu/device/impl/Polygon;->ypoints:[I

    aget v9, v9, v1

    sub-int/2addr v8, v9

    int-to-double v8, v8

    div-double/2addr v6, v8

    iget-object v8, p0, Lorg/microemu/device/impl/Polygon;->xpoints:[I

    aget v8, v8, v1

    int-to-double v8, v8

    add-double/2addr v6, v8

    cmpg-double v4, v4, v6

    if-gez v4, :cond_2

    .line 144
    if-nez v0, :cond_3

    move v0, v11

    .line 141
    :cond_2
    :goto_1
    add-int/lit8 v2, v1, 0x1

    .local v2, i:I
    move v3, v1

    move v1, v2

    goto :goto_0

    .end local v2           #i:I
    :cond_3
    move v0, v10

    .line 144
    goto :goto_1

    :cond_4
    move v4, v0

    .line 196
    .end local v1           #i:I
    .end local v3           #j:I
    .end local v0           #c:Z
    :goto_2
    return v4

    :cond_5
    move v4, v10

    goto :goto_2
.end method

.method public getBounds()Lorg/microemu/device/impl/Rectangle;
    .locals 1

    .prologue
    .line 121
    iget-object v0, p0, Lorg/microemu/device/impl/Polygon;->bounds:Lorg/microemu/device/impl/Rectangle;

    return-object v0
.end method
